Supervised Learning
Important:
在开始学习之前,需要选择一个预测函数
Linear Regression
线性回归算法处理的
预测函数
误差函数
Least Mean Squares
Gradient Descent 属于递归算法
- Batch Gradient Descent 每一轮更新时的梯度来自于整个数据集。在数据集不大时可以使用
- Stochastic Gradient Descent 每一轮更新时的梯度依次取遍整个数据集
- Mini-Batch Gradient Descent ?
Gradient Descent 中单参数的更新。这个公式的意义是直观的,即以一定的学习速率逆着误差函数
在线性回归问题中代入
仍然有直观性,
Normal Equation
对线性回归问题直接解出封闭解
计 $$X=\begin{bmatrix}-x^{(1)}- \ -x^{(2)}- \ \cdots \ -x^{(m)}-\end{bmatrix}$$
则 $$\begin{aligned}J(\theta) & = \frac12\sum_{i = 1}^m(h_{\theta}(x^{(i)})-y^{(i)})^2 \ & = \frac12(X\theta-\symbfit y)^T(X\theta-\symbfit y)\end{aligned}$$
令
Moore–Penrose Inverse 解决最小二乘法在常规逆意义下的无解的情况
wikipedia fandom
Probablistic Interpretation
解释了为什么误差函数
那我们可以假设数据集中的数据点满足(注意现实数据已经由数据集数据代替,在学习过程中不需要考虑,我们假定数据集是良好选取的,可以代表现实数据)$$y^{(i)}:=\theta^Tx^{(i)}+\epsilon^{(i)}$$其中
其中的
我们通过计算数据集中输出数据在假设模型中出现的概率来判断
进一步地有 $$p(y^{(i)}|x^{(i)};\theta)=\frac1{\sqrt{2\pi}\sigma}\exp(-\frac{(y^{(i)}-\theta^Tx^{(i)})^2}{2\sigma^2})$$假设各组数据相互独立就有$$p(\symbfit y|X;\theta)=\prod_{i=1}^m p({y^{(i)}|x^{(i)};\theta})$$它是
将其视为
注意
Locallly weighted linear regression
了解 underfitting 和 overfitting 现象,前者是由于重要的特征没有参与建模,后者是由于过于关注模型的细节噪点
locally weighted linear regression is to fit
locally weighted linear regression 是一个 non-parametric learning algorithm。non-parametric 指的是仍然需要保留整个数据集才能进行查询,而不是只留下参数就能进行查询。
Classification and logistic regression
Logistic Regression
用于解决 binary classification 问题
继续采用和 Linear regression 本质相同的算法,不过
logistic regression 递归的公式 $$\theta_j := \theta_j +\alpha (y^{(i)} - h_\theta(x^{(i)}))x_j^{(i)}$$其推导可以类比 linera regression 中对
细节:推导过程中为了方便定义了
logistic regression 和 linear regression 的递归公式的形式如此相似也是有深层原因的
也可以采用另一种推导,利用与 non-linear model 统一的
Digression: the perceptron learning algorithm
这个算法有一些历史的古板影子。
仅仅采用不同的
Multi-class classification
整体上采用 k 组独立参数,并使用 softmax 规整化。迭代公式推导见 Multi-class classification
Newton's method for optimizing
对
它比 gradient descent 收敛得快,但单次迭代的计算代价更大。
Generalized Linear Models (GLMs)
The exponential family
由一组
基于如下三个假设,可以构建 GLM: